import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/*
 * @author zzr
 * @date: 2025/03/14  16:15
 * @description:测试顺序表
 */
public class Test {
    public static void main(String[] args) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        arrayList.add(1);
        arrayList.add(2);
        arrayList.add(3);
        arrayList.add(4);
        arrayList.add(5);
        for (int i = 0; i < arrayList.size(); i++) {
            System.out.print(arrayList.get(i) + " ");
        }
        System.out.println();
        for (Integer integer : arrayList) {
            System.out.print(integer + " ");
        }
        System.out.println();

        Iterator<Integer> it = arrayList.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();
        ListIterator<Integer> it2 = arrayList.listIterator();
        while (it2.hasNext()) {
            System.out.print(it2.next() + " ");
        }
        System.out.println();

        ListIterator<Integer> it3 = arrayList.listIterator(arrayList.size());
        while (it3.hasPrevious()) {
            System.out.print(it3.previous() + " ");
        }

    }

}
